import random

import globalvars
import butterfly

# TODO: Create an interface for levels to save themselves.


class Level:	# TODO: Decide if this should derivate from pygame.sprite.Sprite.
	def __init__(self):
		self.a = 100.0
		self.f = 0
	
	def q(self):
		return 100/(self.a) + 2

	def update(self):
		"""Called when ever a frame is rendered, this should create new enemies etc."""
		self.f += 1	
		if self.f > self.a + 4:
			self.f = 0
			b = butterfly.Butterfly([random.randint(0, globalvars.resolution[0]-15), 0])
			globalvars.objects_tropical.add(b)
			globalvars.objects_draw.add(b)
			#Globals.ObjectsSelectable.add(b)
			self.a -= self.a/100
			#if self.FramesToNext > 2:
			#	self.FramesToNext -= 1

